<%@include file="startUpIncludes.jsp" %>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>
            Edit Appointment
        </title>
        
    
	 <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>

    <!--Includes-->
	<link href="../css/mobiscroll-2.3.1.custom.min.css" rel="stylesheet" type="text/css" />
	<script src="../js/mobiscroll-2.3.1.custom.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    function myFunction()
    {
    	var value = $("#datepicker").val(); 
        var days= ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];       
        var strDate = value;
        var dateParts = strDate.split("/");
        var date = new Date(dateParts[2], (dateParts[1] - 1), dateParts[0]);
        $("#dayName #day").val(days[date.getDay()]);
    }
    
    
    	function formvalidation(submit) {
    	if (submitted) {
    	//alert("Form already submitted, please be patient");
    	return false;}

    	// field validations go here

    	if (!submitted) {
    	form.submitit.disabled=true;
    	submitted = 1;
    	form.submit();}
    	}
    	
    
</script>
    </head>
    <body>
    <jsp:include page="header.jsp" >
		<jsp:param value="true" name="loggedIn"/>
	</jsp:include>
    <div class="wrap">
	<div class="fitBG">
        <div class="main">
		<%@include file="basicLeftMenu.jsp" %>
            <div class="content">
				<jsp:include page="tabs.jsp" >
					<jsp:param value="leads" name="currentPage"/>
				</jsp:include>
                <div class="tab-content">
                <h3>Edit Appointment</h3>
                <span class="numberError error-block">Please enter a valid number.</span>
                <form:form class="new-lead-form" method="post" action="/sales/s/edit-appointment" commandName="appointmentForm">
                
                <form:errors path="*" cssClass="error-block"/>
                <div class="btns">
                <input type="submit" onclick="formvalidation(this);" value="Save" class="form-btn"/><a  href="/sales/s/viewLead?id=${parentId}" class="form-btn">Cancel</a>
                </div>
                <div class="form-row">
                <input type="hidden" name="id" value="${id}"/>
                <input type="hidden" name="parentId" value="${parentId}"/>
                <input type="hidden" name="parentType" value="${parentType}"/>
                    <h4>Appointment Information</h4>
                    <div class="info"><label>Appointment Owner: </label><span>${userDetails.fName} ${userDetails.lName}</span></div>
                    <div class="input-col">
                    
                        <label>Sales Man    *: </label>
                        <form:select  class="TB" path="salesMan">
                        <c:forEach items="${salesMen}" var="salesMan">
                        	<c:choose>

	                        	<c:when test="${salesMan.id == appointmentForm.salesMan}">
	                            	<option value="${salesMan.id}" selected="selected">${salesMan.fName}</option>
	                        	</c:when>
	                        	<c:otherwise>
	                            	<option value="${salesMan.id}">${salesMan.fName}</option>
	                            </c:otherwise>
                        	</c:choose>
                         </c:forEach>
                        </form:select>
                       
                        <label>Contacted Person   * : </label>
                        <form:select  class="TB" path="contactedPerson">
                        <c:forEach items="${contacts}" var="contact">
                        	<c:choose>

	                        	<c:when test="${contact.id == appointmentForm.contactedPerson}">
	                            	<option value="${contact.id}" selected="selected">${contact.fName}</option>
	                        	</c:when>
	                        	<c:otherwise>
	                            	<option value="${contact.id}">${contact.fName}</option>
	                            </c:otherwise>
                        	</c:choose>
                         </c:forEach>
                        </form:select>
                        <label>Comment: </label>
                        <form:textarea class="TB" path="comment" placeholder="Enter your comment on the appointment..."></form:textarea>
                    </div>
                    <div class="input-col">
                        <label>Date   * : </label>
                        <jsp:include page="calendar-jquery.jsp" >
							<jsp:param value="datepicker" name="inputDateId"/>
						</jsp:include>
                        <form:input type="text" class="TB" path="date" id="datepicker" name="datepicker" onchange="myFunction();"/>
                        <label>Day* : </label>
                        <div id="dayName">
                        <form:input class="TB" path="day" id="day" readonly="true"/>
						</div>
                        <label>Starting Time   * : </label>
                        <jsp:include page="time-jquery.jsp" >
							<jsp:param value="time" name="inputTimeId"/>
						</jsp:include>
                        <form:input type="text" class="TB" path="time" id="time"/>
                        <label>Ending Time   * : </label>
                         <jsp:include page="time-jquery.jsp" >
							<jsp:param value="endtime" name="inputTimeId"/>
						</jsp:include>
                        <form:input type="text" class="TB" path="meetingDuration" id="endtime"/>
                    </div>
                </div>
                <div class="form-row">
                    <h4>Meeting Information</h4>
                    <div class="input-col">
                        <label>Confirmation date expected: </label>
                        <form:radiobutton class="RdCh" path="confirmationDateExpected" value="true"/><span class="RdCh">yes</span>
                        <form:radiobutton class="RdCh" path="confirmationDateExpected" value="false"/><span class="RdCh">No</span>
                        <label>Meeting done: </label>
                        <form:radiobutton class="RdCh" path="meetingDone" value="true"/><span class="RdCh">yes</span>
                        <form:radiobutton class="RdCh" path="meetingDone" value="false"/><span class="RdCh">No</span>
                        <label>Customer need: </label>
                        <form:textarea class="TB" path="customerNeed" placeholder="Enter customer need here..."></form:textarea>
                        <label>Demo done: </label>
                        <form:radiobutton class="RdCh" path="demoDone" value="true"/><span class="RdCh">yes</span>
                        <form:radiobutton class="RdCh" path="demoDone" value="false"/><span class="RdCh">No</span>
                        <label>Offer submitted: </label>
                        <form:radiobutton class="RdCh" path="offerSubmitted" value="true"/><span class="RdCh">yes</span>
                        <form:radiobutton class="RdCh" path="offerSubmitted" value="false"/><span class="RdCh">No</span>
                    </div>
                    <div class="input-col">
                        <label>Discount done: </label>
                        <form:radiobutton class="RdCh" path="discountDone" value="true"/><span class="RdCh">yes</span>
                        <form:radiobutton class="RdCh" path="discountDone" value="false"/><span class="RdCh">No</span>
                        <label>Competitor offer: </label>
                        <form:radiobutton class="RdCh" path="competitorOffer" value="true"/><span class="RdCh">yes</span>
                        <form:radiobutton class="RdCh" path="competitorOffer" value="false"/><span class="RdCh">No</span>
                        <label>Reply period: </label>
                        <form:input type="text" class="TB" path="replyPeriod"/>
                        <label>Deal closing done: </label>
                        <form:radiobutton class="RdCh" path="dealClosingDone" value="true"/><span class="RdCh">yes</span>
                        <form:radiobutton class="RdCh" path="dealClosingDone" value="false"/><span class="RdCh">No</span>
                        <label>Deal closing reason: </label>
                        <form:textarea class="TB" path="dealClosingReason" placeholder="Enter deal closing reason..."></form:textarea>
                    </div>
                </div>
                <div class="form-row">
                    <h4>Next Follow Up Information</h4>
                    <div class="input-col">
                        <label>Next Follow Up: </label>
                        <form:radiobutton class="RdCh" path="nextFollowUp" value="true"/><span class="RdCh">yes</span>
                        <form:radiobutton class="RdCh" path="nextFollowUp" value="false"/><span class="RdCh">No</span>
                        <label>Next Follow Up Type: </label>
                        <form:select class="TB" path="nextFollowUpType">
                        	<form:option value="none">--none--</form:option>
	                        <form:option value="call">Call</form:option>
	                        <form:option value="appointment">Appointment</form:option>
                        </form:select>
                    </div>
                    <div class="input-col">
                        <label>Next Follow Up Date: </label>
                        <jsp:include page="calendar-jquery.jsp" >
							<jsp:param value="datepicker2" name="inputDateId"/>
						</jsp:include>
                        <form:input class="TB" path="nextFollowUpDate" id="datepicker2"/>
                        <label>Next Follow Up Details: </label>
                        <form:input class="TB" path="nextFollowUpDetails"/>
                    </div>
                </div>
                <div class="btns">
                <input type="submit" value="Save" class="form-btn"/><a href="/sales/s/viewLead?id=${parentId}" class="form-btn">Cancel</a>
                </div>
                </form:form>
                </div>
            </div>
        </div>
        
    <%@include file="footer.jspf" %>
    </div>
    </div>

    </body>
</html>